<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        // json的数据格式
        //JSON.stringify--可以将JSON对象转化为字符串
        var obj = {
            name:"lisi",
            age:18
        }
        var arr = [
        {
            name:"lisi",
            age:14
        }
        ]
        var res = JSON.stringify(obj);
        console.log(typeof res);
        console.log(JSON.stringify(arr))
        // JSON.parse可以将Json格式的字符串转化为JSON对象
        var str = '{"name":"lisi","age":18}'
        var sum = JSON.parse(str);
        console.log(sum)
    </script>
</body>
</html>